﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RRHeartBeatRequest", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RRHeartBeatRequest))]
    public class RRHeartBeatRequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRRHeartBeatRequest clazz;
        
        public RRHeartBeatRequestSerializer(IRRHeartBeatRequest clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("seire_sisend1");
            if (clazz.SeireSisend1!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SeireSisend1))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SeireSisend1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("seire_sisend2");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "double");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDouble(((double)(clazz.SeireSisend2))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="seire_sisend1") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRHeartBeatRequest>seire_sisend1");
                }
                clazz.SeireSisend1 = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("seire_sisend1")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRHeartBeatRequest>seire_sisend1", Reader.LocalName);
            }
            if (Reader.LocalName=="seire_sisend2") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRHeartBeatRequest>seire_sisend2");
                }
                clazz.SeireSisend2 = new global::Xtee.Core.Schema.XsdDouble(Reader.ReadElementString("seire_sisend2")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRHeartBeatRequest>seire_sisend2", Reader.LocalName);
            }
        }
    }
}
